<template>
  <Menu accordion :active-name="activeRoute" >
    <Submenu :name="index" v-for="(item,index) in menuConfig" :key="item.title" >
      <template slot="title">
        <Icon type="ios-paper" />{{item.title}}
      </template>
      <MenuItem :name="value.index" v-for="value in item.subs" :key="value.index" :to="value.index">
        {{value.title}}
      </MenuItem>
    </Submenu>
  </Menu>
</template>

<script>
import bus from './bus.js';
export default {
  data() {
    return {
      isFlex:false,
      menuConfig: [
        {
          icon: "el-icon-s-tools",
          title: "系统管理",
          subs: [
            {
              index: "/department",
              title: "部门管理"
            },
            {
              index: "/employee",
              title: "员工管理"
            },
            {
              index: "/permission",
              title: "权限管理"
            },
            {
              index: "/roles",
              title: "角色管理"
            }
          ]
        },
        {
          icon: "el-icon-s-management",
          title: "数据管理",
          subs: [
            {
              index: "/sysdictionary",
              title: "字典目录"
            },
            {
              index: "/sysdictionaryitem",
              title: "字典明细"
            }
          ]
        },
        {
          icon: "el-icon-service",
          title: "客户管理",
          subs: [
            {
              index: "/customerlist",
              title: "客户列表"
            },
            {
              index: "/pcustomerlist",
              title: "潜在客户"
            },
            {
              index: "/rpoolcustomer",
              title: "客户池"
            },
            {
              index: "/failcustomer",
              title: "失败客户"
            }
          ]
        },
        {
          icon: "el-icon-s-custom",
          title: "客户历史",
          subs: [
            {
              index: "/customertracehistory",
              title: "跟进历史"
            }
          ]
        },
        {
          icon: "el-icon-s-data",
          title: "报表统计",
          subs: [
            {
              index: "/customerreport",
              title: "潜在客户报表"
            }
          ]
        }
      ]
    };
  },
  created() {
    bus.$on("flexible",res =>{
      console.log(res)
      this.isFlex = res;
    })
  },
  computed: {
    // 默认当前选中的
    activeRoute() {
      return this.$route.path;
    },
  },
};
</script>

<style lang="less" scoped>
.ivu-menu.ivu-menu-light.ivu-menu-vertical {
  position: absolute;
  left: 0;
  height: calc(~"100vh - 60px");
}
</style>   
